package com.qlogic.commons.utils.os;

import java.io.IOException;
import java.io.InputStream;

import com.qlogic.commons.utils.io.BinaryStreamsUtils;

public class TestOsCommandExecuter {
	public static void main (String [] args) throws IOException {
//		 executeOneCommand ();
		// executeMultiCommands ();
		executeWinExecCommand ();
	}
	
	protected static void executeOneCommand () throws IOException {
		InputStream is = 
			new OsCommandExecuter ().execute ("dir d:\\").format ("MyCommand");
		BinaryStreamsUtils.copy (is, System.out);
	}
	
	protected static void executeMultiCommands () throws IOException {
		OsCommandExecuter executer = new OsCommandExecuter ();
		executer.execute (new String [] {"dir d:\\", "dir c:\\"});
		
		InputStream is1 = executer.getResult ("dir d:\\").format ("dir d:\\");	
		BinaryStreamsUtils.copy (is1, System.out);
		
		InputStream is2 = executer.getResult ("dir c:\\").format ("dir c:\\");	
		BinaryStreamsUtils.copy (is2, System.out);
		
	}
	
	protected static void executeWinExecCommand () throws IOException {
		InputStream is = 
			new OsCommandExecuter ().execute ("mkdir bobo").format ("Select 1");
		BinaryStreamsUtils.copy (is, System.out);
	}
	
}
